<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/lib/layui-v2.6.8/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/public.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">

        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>

    </div>
</div>
<script src="/lib/layui-v2.6.8/layui.js" charset="utf-8"></script>
<script src="/js/lay-config.js?v=2.0.0" charset="utf-8"></script>
<script>
    layui.use(['form', 'table'], function () {
        var $ = layui.jquery,
            layer = layui.layer,
            table = layui.table;

        $.get('/admin/user/getCurrent', {}, function (re) {
            if (re.code == 0) {
                layui.use('watermark', function (watermark) {
                    watermark({watermark_txt: re.data.name});
                });
            }
        }, 'json');

        layui.delFile = function (f) {
            layer.confirm('确定删除吗 ?', function (i) {
                $.post('/admin/db_log/delete', {'file': f}, function (re) {
                    if (re.code == 0) {
                        table.reload('currentTableId');
                    } else {
                        layer.msg('删除失败, ' + re.msg);
                    }
                }, 'json');
                layer.close(i);
            });
        };

        table.render({
            elem: '#currentTableId',
            url: '/admin/db_log/list',
            done: function () {
                $('body, html').animate({
                    scrollTop: 0
                }, 100);
            },
            cols: [[
                {field: 'name', title: '日志'},
                {title: '下载', width: 85, templet: function (row) {
                    return '<a class="layui-btn layui-btn-warm layui-btn-xs" target="_blank" href="/admin/db_log/download?file=' + encodeURIComponent(row.name) + '"><i class="layui-icon layui-icon-download-circle"></i>下载</a>';
                }},
                {title: '删除', width: 85, templet: function (row) {
                    return '<button type="button" class="layui-btn layui-btn-danger layui-btn-xs" onclick="javascript:layui.delFile(\'' + row.name + '\');"><i class="layui-icon">&#xe640;</i>删除</button>';
                }},
            ]],
            limit: 10000,
            page: false,
            skin: 'line',
            width: 600
        });

    });
</script>

</body>
</html>